package com.zhangck.bos2_0.action.transit;

import java.util.HashMap;
import java.util.Map;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Actions;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionContext;
import com.zhangck.bos2_0.Service.transit.TransitInfoServices;
import com.zhangck.bos2_0.common.BaseAction;

import cn.itcast.bos.domain.system.User;
import cn.itcast.bos.domain.transit.TransitInfo;

/** 
* @author 上午茶
* @version 创建时间：2018年6月19日 下午3:01:14 
* 类说明 
*/
@ParentPackage("json-default")
@Namespace("/")
@Scope("prototype")
@Actions
@Controller
public class TransitInfoAction extends BaseAction<TransitInfo>{
	
	@Autowired
	private TransitInfoServices transitInfoServices;
	
	private String wayBillIIds;
	
	
	public void setWayBillIIds(String wayBillIIds) {
		this.wayBillIIds = wayBillIIds;
	}

	@Action(value = "transit_create", results = { @Result(name = "success", type = "json") })
	public String transit_create() {
		Map<String, Object> map = new HashMap<String, Object>();
		try {
			transitInfoServices.createTransitInfo(wayBillIIds);
			map.put("success", true);
			map.put("msg", "操作成功开始中转");
		} catch (Exception e) {
			e.printStackTrace();
			map.put("success", false);
			map.put("msg", "操作失败");
		}
		ActionContext.getContext().getValueStack().push(map);
		return "success";
	}
	
	@Action(value = "transit_page", results = { @Result(name = "success", type = "json") })
	public String transit_page() {
		Pageable pageable = new PageRequest(page-1, rows);
		
		 Page<TransitInfo> page = transitInfoServices.findPage(pageable);
		
		 pushPageDataValueStack(page);
		return "success";
	}
	
	
}
